package com.example.a22310.myapplication.Beans;


import android.content.Intent;
import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.databinding.BindingAdapter;
import android.view.View;
import android.widget.ImageView;

import com.example.a22310.myapplication.Activity.GameDatail;
import com.squareup.picasso.Picasso;

import java.io.Serializable;
import java.util.List;

import static com.example.a22310.myapplication.GloableClass.Yuejian.IMG_URL;

public class Race {

    /**
     * code : 200
     * racelist : [{"game_id":"6","game_name":"比赛","game_pic":"59b2424e69a23.png","game_time":"2017-09-07 00:00:00","game_place":"www.baidu.com","game_intro":"好玩","game_webaddress":"东软"},{"game_id":"5","game_name":"3","game_pic":"","game_time":"0000-00-00 00:00:00","game_place":"3","game_intro":"1","game_webaddress":"1"},{"game_id":"7","game_name":"V型半部分不反对","game_pic":"2.jpg","game_time":"2017-10-23 13:01:37","game_place":"dsssfbb","game_intro":"dsvf","game_webaddress":"dsfsdv"}]
     */

    private int code;
    private List<RacelistBean> racelist;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public List<RacelistBean> getRacelist() {
        return racelist;
    }

    public void setRacelist(List<RacelistBean> racelist) {
        this.racelist = racelist;
    }

    public static class RacelistBean extends BaseObservable implements Serializable {
        /**
         * game_id : 6
         * game_name : 比赛
         * game_pic : 59b2424e69a23.png
         * game_time : 2017-09-07 00:00:00
         * game_place : www.baidu.com
         * game_intro : 好玩
         * game_webaddress : 东软
         */

        private String game_id;
        private String game_name;
        private String game_pic;
        private String game_time;
        private String game_webaddress;
        private String game_intro;
        private String game_place;



        public RacelistBean() {
        }

        public RacelistBean(String game_id,  String game_name, String game_pic, String game_time,
                            String game_place,
                            String game_intro,String game_webaddress)
        {


            this.game_id = game_id;
            this.game_name = game_name;
            this.game_pic=game_pic;
            this.game_time =game_time;
            this.game_webaddress=game_webaddress;
            this.game_intro = game_intro;
            this.game_place = game_place;
        }

        @BindingAdapter("game_pic")
        public static void loadInternetImage(ImageView iv, String game_pic) {
            game_pic = IMG_URL+game_pic;
            Picasso.with(iv.getContext()).load(game_pic).into(iv);
        }

        @Override
        public String toString() {



            return "ClublistBean{" +
                    "game_id='" + game_id + '\'' +
                    ", game_name='" + game_name + '\'' +
                    ", game_pic='" + game_pic + '\'' +
                    "game_time='" + game_time + '\'' +
                    ", game_place='" + game_place + '\'' +
                    ", game_intro='" + game_intro + '\'' +
                    "game_webaddress='" + game_webaddress + '\'' +
                    '}';
        }

        public void onItemClick(View view){
            Intent intent=new Intent(view.getContext(),GameDatail.class);

            RacelistBean RacelistBean= new RacelistBean();
            RacelistBean.setGame_id(getGame_id());
            RacelistBean.setGame_name(getGame_name());
            RacelistBean.setGame_intro(getGame_intro());
            RacelistBean.setGame_pic(getGame_pic());
            RacelistBean.setGame_place(getGame_place());
            RacelistBean.setGame_time(getGame_time());
            RacelistBean.setGame_webaddress(getGame_webaddress());

            intent.putExtra("race",RacelistBean);
            view.getContext().startActivity(intent);
        }

        @Bindable



        public String getGame_id() {
            return game_id;
        }

        public void setGame_id(String game_id) {
            this.game_id = game_id;
        }

        public String getGame_name() {
            return game_name;
        }

        public void setGame_name(String game_name) {
            this.game_name = game_name;
        }

        public String getGame_pic() {
            return IMG_URL+game_pic;
        }

        public void setGame_pic(String game_pic) {
            this.game_pic = game_pic;
        }

        public String getGame_time() {
            return game_time;
        }

        public void setGame_time(String game_time) {
            this.game_time = game_time;
        }

        public String getGame_place() {
            return game_place;
        }

        public void setGame_place(String game_place) {
            this.game_place = game_place;
        }

        public String getGame_intro() {
            return game_intro;
        }

        public void setGame_intro(String game_intro) {
            this.game_intro = game_intro;
        }

        public String getGame_webaddress() {
            return game_webaddress;
        }

        public void setGame_webaddress(String game_webaddress) {
            this.game_webaddress = game_webaddress;
        }
    }

}
